Inserir subtítulo

Autor
Afiliação

Inserir autor

Transparência Brasil

Data de Publicação

11.ago.2025

Data de Modificação

11.ago.2025

Código
library(tidyverse)
library(here)
library(palmerpenguins)
library(DT)
source(here("setup/rsetup.R"), encoding = "utf-8")

Resumo

O objetivo deste relatório é…

Principais resultados:

  • Destaque 1.
  • Destaque 2.

Análise

Lorem ipsum dolor sit amet, quis amet tincidunt fames eu vestibulum, ligula. Eleifend quis pellentesque donec pharetra auctor mi nibh maximus taciti. Venenatis egestas duis justo sed adipiscing non ut scelerisque ullamcorper tempor. Turpis odio sociis phasellus ridiculus quis egestas felis natoque molestie, nascetur. Nisi nec fusce amet malesuada ut scelerisque ut ac. Dolor habitant auctor leo consectetur in. Litora vitae aliquet neque. At vel urna ut arcu, nullam vestibulum sed auctor sodales, sagittis in vitae est, at. Lorem ipsum felis ultricies vel, lobortis vitae purus in. Mauris nulla risus purus habitasse consequat. Sodales nisi, laoreet egestas risus nibh himenaeos. Taciti, nullam tincidunt, volutpat egestas in pulvinar.

Datasets

Código
iris %>%
  datatable(
    rownames = FALSE,
    filter = "top",
    escape = FALSE,
    options = list(pageLength = 10, searchHighlight = TRUE)
  ) %>%
  formatStyle(columns = 1:5, fontSize = "80%")

Gráfico

Código
iris %>%
  ggplot(aes(
    x = Petal.Length,
    y = Petal.Width,
    fill = Species,
    color = after_scale(colorspace::darken(fill, .4))
  )) +
  geom_point(shape = 21, size = 3) +
  scale_fill_manual(values = c(
    "virginica" = cores_tb[["azul"]],
    "versicolor" = cores_tb[["laranja"]],
    "setosa" = cores_tb[["cinza_claro"]]
  )) +
  labs(
    title = "Um gráfico importante"
  )

Algumas vezes precisamos exibir o código, podemos fazer assim:

# testando uma função:
awesome_function <- function(x) {
  stopifnot(is.integer(x))
  a <- x + 10L
  b <- x + 11L
  c <- a + b
  message("\nSomamos a com b!\n")
  return(c)
}

awesome_function(30L)
#> 
#> Somamos a com b!
#> [1] 81

# filtando um dataset
iris2 <- iris %>% tidylog::filter(Species == "setosa")
#> filter: removed 100 rows (67%), 50 rows remaining

Usando tips

Nota

Note that there are five types of callouts, including: note, warning, important, tip, and caution.

Tip with Title

This is an example of a callout with a title.

This is an example of a ‘folded’ caution callout that can be expanded by the user. You can use collapse="true" to collapse it by default or collapse="false" to make a collapsible callout that is expanded by default.

Usando abas

Código
iris %>%
  ggplot(aes(
    x = Petal.Length,
    y = Petal.Width,
    fill = Species,
    color = after_scale(colorspace::darken(fill, .4))
  )) +
  geom_point(shape = 21, size = 3) +
  scale_fill_manual(values = c(
    "virginica" = cores_tb[["azul"]],
    "versicolor" = cores_tb[["laranja"]],
    "setosa" = cores_tb[["cinza_claro"]]
  )) +
  labs(
    title = "Um gráfico importante"
  )

Código
iris %>%
  group_by(Species) %>%
  summarise(across(where(is.double), mean, .names = "{.col}")) %>%
  pivot_longer(-Species) %>%
  mutate(
    Species = reorder(Species, value),
    name = reorder(name, value)
  ) %>%
  ggplot(aes(
    x = Species,
    y = value,
    fill = name,
    color = after_scale(colorspace::darken(fill, .4))
  )) +
  geom_col(position = "dodge") +
  scale_fill_manual(values = c(
    "Sepal.Length" = cores_tb[["azul"]],
    "Petal.Length" = cores_tb[["laranja"]],
    "Sepal.Width" = cores_tb[["cinza_quase_branco"]],
    "Petal.Width" = cores_tb[["cinza_claro"]]
  )) +
  labs(
    title = "Média de Iris"
  )

Interatividade

Trabalhando com gráficos em chunks OJS.

Código
# glimpse(penguins)

# envia dataset de R para OJS
ojs_define(palmerPenguins = penguins)
Código
penguins = transpose(palmerPenguins)

// range/slide de  32 até 50
viewof bill_length_min = Inputs.range(
  [32, 50],
  {value: 35, step: 1, label: "Bill length (min):"}
)

//checkbox de Islands
viewof islands = Inputs.checkbox(
  ["Torgersen", "Biscoe", "Dream"],
  { value: ["Torgersen", "Biscoe"],
    label: "Islands:"
  }
)

// aplica filtro no dataset
filtered = penguins.filter(function(penguin) {
  return bill_length_min < penguin.bill_length_mm &&
         islands.includes(penguin.island);
})

// plot
Plot.rectY(filtered,
  Plot.binX(
    {y: "count"},
    {x: "body_mass_g", fill: "species", thresholds: 20}
  ))
  .plot({
    facet: {
      data: filtered,
      x: "sex",
      y: "species",
      marginRight: 80
    },
    marks: [
      Plot.frame(),
    ]
  }
)

Referências

É importante que um relatório contenha:

  • Contexto/objetivo do relatório
  • Breve descrição e/ou dicionário dos dados utilizados
  • Demarcação/limitação temporal do recorte de dados utilizados
  • Análise em si (não apenas plots)

E até opcionais:

  • Highlights/lowlights do processo
  • Referências técnicas ou de negócio